
/**
 * Please modify this class to meet your needs
 * This class is not complete
 */

package com.cctv.ppm.service.progtechreviewfeedback._1_0;

import java.sql.Timestamp;
import java.util.Calendar;
import java.util.logging.Logger;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.xml.bind.annotation.XmlSeeAlso;

import org.apache.commons.lang3.StringUtils;
import com.cctv.ppm.schema.progtechreviewsummary._0.ProgTechReviewFeedbackResponseType;
import com.ctvit.framework.web.context.ContextHolder;
import com.ctvit.wsservice.basedata.domain.ZppmTProtech;
import com.ctvit.wsservice.basedata.service.TaskFeedbackService;

/**
 * This class was generated by Apache CXF 3.1.4
 * 2016-01-12T15:47:50.077+08:00
 * Generated source version: 3.1.4
 * 
 */

@javax.jws.WebService(
                      serviceName = "ProgTechReviewFeedbackService",
                      portName = "PorgTechReviewFeedbackPort",
                      targetNamespace = "http://cctv.com/PPM/service/ProgTechReviewFeedback/1.0",
                      endpointInterface = "com.cctv.ppm.service.progtechreviewfeedback._1_0.ProgTechReviewFeedbck")
                      
public class PorgTechReviewFeedbackPortImpl implements ProgTechReviewFeedbck {

    private static final Logger LOG = Logger.getLogger(PorgTechReviewFeedbackPortImpl.class.getName());

    /* (non-Javadoc)
     * @see com.cctv.ppm.service.progtechreviewfeedback._1_0.ProgTechReviewFeedbck#publish(com.cctv.esb.schema.messagehead._0.RequestHeadType  requestHead ,)com.cctv.ppm.schema.ppm_commondatatypes._0.ProgTechReviewSummaryType  progTechReviewSummary )*
     */
    public com.cctv.ppm.schema.progtechreviewsummary._0.ProgTechReviewFeedbackResponseType publish(com.cctv.esb.schema.messagehead._0.RequestHeadType requestHead,com.cctv.ppm.schema.ppm_commondatatypes._0.ProgTechReviewSummaryType progTechReviewSummary) { 
        LOG.info("Executing operation publish");
        System.out.println(requestHead);
        System.out.println(progTechReviewSummary);
        try {
        	//000:成功,001:非最终技审结果,002:技审单号已存在;003：不存在技审任务
            ProgTechReviewFeedbackResponseType _return = new ProgTechReviewFeedbackResponseType();
            _return.setProgramCode(progTechReviewSummary.getProgramCode());
        	_return.setAudioLanguage(progTechReviewSummary.getAudioLanguage());
        	_return.setSubtitleLanguage(progTechReviewSummary.getSubtitleLanguage());
        	_return.setProgramAuditBillID(progTechReviewSummary.getProgramAuditBillID());
        	TaskFeedbackService taskFeedbackService = ContextHolder.getBean(TaskFeedbackService.class); // 操作类
            if (StringUtils.equals(progTechReviewSummary.getProgSegmentIndex(),progTechReviewSummary.getProgSegmentSum())&&
            		progTechReviewSummary.getTechInspectFinalResult()==0){//最终技审结果
            	ZppmTProtech zppmTProtech=new ZppmTProtech();
            	zppmTProtech.setZProcode(progTechReviewSummary.getProgramCode());
            	zppmTProtech.setZAudVer(progTechReviewSummary.getAudioLanguage().getLangCode());
            	zppmTProtech.setZCapVer(progTechReviewSummary.getSubtitleLanguage().getLangCode());
            	zppmTProtech.setZAuditBillid(progTechReviewSummary.getProgramAuditBillID());
            	zppmTProtech.setZTechinspectDeptid(progTechReviewSummary.getTechInspectDeptID());
            	zppmTProtech.setZTechinspectorid(progTechReviewSummary.getTechInspectorID());
            	zppmTProtech.setZTechinspectResult(String.valueOf(progTechReviewSummary.getTechInspectFinalResult()));
            	zppmTProtech.setZTechinspectTime(new Timestamp(progTechReviewSummary.getTechInspectTime().toGregorianCalendar().getTimeInMillis()));
            	zppmTProtech.setZStatus("0");
            	zppmTProtech.setZCreateTime(new Timestamp(Calendar.getInstance().getTimeInMillis()));
            	int ret=taskFeedbackService.saveProgTechResult(zppmTProtech);
            	if (ret==0){
            		_return.setStatusCode("000");
            	}else if (ret==-1){
            		_return.setStatusCode("002");
            	}else if (ret==-2){
            		_return.setStatusCode("003");
            	}
            }else{
            	_return.setStatusCode("001");
            }
            
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }

    /* (non-Javadoc)
     * @see com.cctv.ppm.service.progtechreviewfeedback._1_0.ProgTechReviewFeedbck#getServiceInfo(com.cctv.esb.schema.monitor._0.GetServiceInfoRequestType  getServiceInfoRequest )*
     */
    public com.cctv.esb.schema.monitor._0.GetServiceInfoResponseType getServiceInfo(com.cctv.esb.schema.monitor._0.GetServiceInfoRequestType getServiceInfoRequest) { 
        LOG.info("Executing operation getServiceInfo");
        System.out.println(getServiceInfoRequest);
        try {
            com.cctv.esb.schema.monitor._0.GetServiceInfoResponseType _return = null;
            return _return;
        } catch (java.lang.Exception ex) {
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }
    }

}
